﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OfficeClip.OpenSource.StyleFix.Drivers
{
    class NamingRules : StyleCopRules
    {
        internal void SA1300_ElementMustBeginWithUpperCaseLetter(ref List<OfficeClip.OpenSource.StyleFix.SFWorkingLine> workingLines)
        {
            foreach (SFWorkingLine workingLine in workingLines)
            {
                if (IsLineViolated(workingLine, "SA1300"))
                {                                   
                    SAObject saob = workingLine.Violations.Find(sao => sao.ErrorId == "SA1300");

                    string methodName = saob.Description.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries).Last();
                    methodName = methodName.TrimEnd('.');
                    string newMethodName = char.ToUpper(methodName.First()) + methodName.Substring(1);
                    workingLine.Line = workingLine.Line.Replace(methodName, newMethodName);
                }
            }
        }
    }
}
